<!DOCTYPE HTML>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no,email=no,date=no,aItemress=no">
	<title>个人中心</title>
	<link rel="stylesheet" type="text/css" href="../../css/base.css" />
	<style type="text/css">
		body {
			background: #F0F1F2;
		}

		.wraper-cont {
			padding: 0 0.15rem;
			background: #ffffff;
			padding-bottom: 0.15rem;
		}

		.add-title {
			height: 0.91rem;
			border-bottom: 1px solid #e6e6e6;
			position: relative;
			box-sizing: border-box;
			margin-bottom: 0.15rem;
		}

		.maxlength {
			font-size: 0.12rem;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: rgba(179, 179, 179, 1);
			line-height: 0.17rem;
			position: absolute;
			bottom: 0.1rem;
			right: 0;
		}

		input {
			width: 100%;
			padding-top: 0.2rem;
			font-size: 0.2rem;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: rgba(77, 77, 77, 1);
			line-height: 0.28rem;
		}

		input::-webkit-input-placeholder {
			font-size: 0.2rem;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: rgba(179, 179, 179, 1);
			line-height: 0.28rem;
		}

		input::-moz-placeholder {
			/* Mozilla Firefox 19+ */
			font-size: 0.2rem;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: rgba(179, 179, 179, 1);
			line-height: 0.28rem;
		}

		input:-moz-placeholder {
			/* Mozilla Firefox 4 to 18 */
			font-size: 0.2rem;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: rgba(179, 179, 179, 1);
			line-height: 0.28rem;
		}

		input:-ms-input-placeholder {
			/* Internet Explorer 10-11 */
			font-size: 0.2rem;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: rgba(179, 179, 179, 1);
			line-height: 0.28rem;
		}

		.add-cont {
			height: 2.17rem;
			border-bottom: 1px solid #eeeeee;
			position: relative;
			margin-bottom: 0.15rem;
		}

		textarea {
			font-size: 0.15rem;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: rgba(77, 77, 77, 1);
			line-height: 0.21rem;
			width: 100%;
			height: 1.9rem;
			overflow-y: scroll;
		}

		textarea::-webkit-input-placeholder {
			font-size: 0.15rem;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: rgba(153, 153, 153, 1);
			line-height: 0.21rem;
		}

		.cont-maxlength {
			position: absolute;
			right: 0;
			bottom: 0.1rem;
			font-size: 0.12rem;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: rgba(179, 179, 179, 1);
			line-height: 0.17rem;
		}

		.add-photo img {
			width: 0.6rem;
			height: 0.6rem;
		}

		.release {
			width: 3.45rem;
			height: 0.46rem;
			background: rgba(0, 90, 147, 1);
			border-radius: 0.06rem;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 0.16rem;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: rgba(255, 255, 255, 1);
			line-height: 0.22rem;
			margin: 0 auto;
			margin-top: 0.4rem;
		}
	</style>
</head>

<body>
	<div id="app" v-cloak="">
		<div class="wraper">
			<div class="wraper-cont">
				<!-- 添加标题 -->
				<div class="add-title">
					<input type="text" placeholder="添加标题" v-model="title" maxlength="30" />
					<div class="maxlength">{{title.length}}/30</div>
				</div>
				<!-- 内容 -->
				<div class="add-cont">
					<textarea name id cols="30" rows="10" placeholder="说说你的想法吧～" v-model="cont"></textarea>
					<div class="cont-maxlength">{{cont.length}}/500</div>
				</div>
				<!-- 上传 -->
				<div class="add-photo">
					<!-- 默认图 -->
					<img @click="set_pic" src="../../image/icons/add-photo.png" alt />
				</div>
			</div>
			<!-- 发布按钮 -->
			<div class="release" @click="submit">发布会员秀</div>
		</div>
	</div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/vue.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/aui-dialog.js"></script>
<script>
	var vm = new Vue({
		el: "#app",
		data: {
			birthdayList: [],
			title: '',
			cont: '',
			img: [],
			imgpath: [],
		},

		methods: {
			submit: function() {
				if (vm.title == '') {
					toast('请输入标题');
					return;
				}
				if (vm.cont == '') {
					toast('请输入内容');
					return;
				}
				var content = vm.cont
				content = ucs2_to_utf16(content)
				var title = vm.title
				title = ucs2_to_utf16(title)
				//alert(content)
				//alert(title)
					// get_data('api/xiaoyouquan/xyqPublish', {
					// 	token: $api.getStorage('token'),
					// 	title: title,
					// 	content: content,
					// 	img: vm.img.join(','),
					// 	video: vm.video.join(','),
					// 	video_img: vm.video_img.join(','),
					// }, function(ret) {
					// 	toast(ret.msg)
					// 	if (ret.status) {
					// 		vm.title = ''
					// 		vm.content = ''
					// 		vm.img = []
					// 		vm.imgpath = []
					// 		vm.video = []
					// 		vm.video_img = []
					// 		send_event('publishok')
					// 	}
					// })
			},
			get_info: function() {
				get_data('api/User/birthdayList', {
					token: $api.getStorage('token')
				}, function(ret) {
					if (ret.status) {
						vm.birthdayList = ret.data.user_family;
					}
				})
			},
		}
	})

	apiready = function() {
		vm.get_info();
	};

	function set_pic() {
		api.actionSheet({
			title: '',
			cancelTitle: '取消',
			buttons: ['上传图片', '拍摄照片'], //'上传视频'录制视频,
			style: {
				fontNormalColor: '#333',
			},
		}, function(ret, err) {
			if (ret) {
				// 上传图片
				if (ret.buttonIndex == 1) {
					var max = 3 - vm.img.length;
					if (max < 1) {
						return;
					}
					select_album(max, function(ret) {
						//alert(JSON.stringify(ret))
						 var pic_path = ret.path
							// alert(pic_path)
						 post_img('api/UpFiles/upload', pic_path, function(ret) {
						 	vm.img.push(ret.data.pic_id);
						 	vm.imgpath.push(ret.data.url);
							//vm.video.push(ret.data.url);
						 })
					})
				} else {
					//拍摄照片
					api.getPicture({
						sourceType: 'camera',
						encodingType: 'jpg',
						mediaValue: 'pic',
						// allowEdit: true,
						destinationType: 'url',
						quality: 92,
					}, function(ret, err) {
						if (ret) {
							if (ret.data != '') {
								//alert(JSON.stringify(ret))
								post_img('api/UpFiles/upload', ret.data, function(ret) {
									// vm.img.push(ret.data.pic_id);
									//alert(JSON.stringify(ret))
									vm.imgpath.push(ret.data.url);
								})
							}
						}
					});
				}
			}

		})

	}
</script>

</html>
